package com.lb.ai.common.response.code;

import com.lb.ai.common.response.IResultCode;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 系统模块响应码
 *
 * @author LiuB
 */
public class SystemModule extends ResultCodeModule {
    
    public SystemModule() {
        super(4, "系统模块");
    }
    
    @Getter
    @AllArgsConstructor
    public enum Code implements IResultCode {
        
        // 系统错误 1xx
        SYSTEM_ERROR(101, "系统错误"),
        SYSTEM_BUSY(102, "系统繁忙"),
        SYSTEM_TIMEOUT(103, "系统超时"),
        
        // 服务错误 2xx
        SERVICE_ERROR(201, "服务异常"),
        SERVICE_UNAVAILABLE(202, "服务不可用"),
        SERVICE_DEGRADED(203, "服务已降级"),
        
        // 网关错误 3xx
        GATEWAY_ERROR(301, "网关异常"),
        GATEWAY_TIMEOUT(302, "网关超时"),
        GATEWAY_CONNECT_ERROR(303, "网关连接失败"),
        
        // 数据库错误 4xx
        DB_ERROR(401, "数据库异常"),
        DB_TIMEOUT(402, "数据库超时"),
        DB_DEADLOCK(403, "数据库死锁"),
        DB_DUPLICATE_KEY(404, "数据重复"),
        
        // 缓存错误 5xx
        CACHE_ERROR(501, "缓存异常"),
        CACHE_TIMEOUT(502, "缓存超时"),
        CACHE_FULL(503, "缓存已满"),
        
        // 消息队列错误 6xx
        MQ_ERROR(601, "消息队列异常"),
        MQ_TIMEOUT(602, "消息队列超时"),
        MQ_FULL(603, "消息队列已满");
        
        private final Integer code;
        private final String message;
        
        @Override
        public Integer getCode() {
            return new SystemModule().generateCode(code);
        }
    }
    
    @Override
    public IResultCode[] getCodes() {
        return Code.values();
    }
} 